use opencv::{ prelude::*, videoio, Result, core::{Mat, Vector}, imgcodecs};
// 拍照
pub fn run() -> Result<()>{
	// 打开摄像机
	let mut cam = videoio::VideoCapture::new(0, videoio::CAP_ANY).unwrap();
	// 判断相机是否打开
	if videoio::VideoCapture::is_opened(&cam).unwrap() {
		eprintln!("摄像机已打开！");
	}
	let mut frame = Mat::default();
    let mut buf = Vector::new();

	cam.read(&mut frame).unwrap();
	buf.clear();

	let _ = imgcodecs::imencode(".jpg", &frame, &mut buf, &Vector::new());
	// 以图片形式将捕获图像存储到本地
	let _ = imgcodecs::imwrite("upload/b.jpg", &frame, &Vector::new());

    Ok(())
}